# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: xguo

import coin.exchange.kraken.kr_rest.product as exchange_product
import coin.exchange.kraken.kr_rest.public_client as pubc
from coin.exchange.base.kr_rest.feed_base import FeedBase


class KrakenFeed(FeedBase):
  ProductType = exchange_product.KrakenProduct

  def __init__(self, product):
    FeedBase.__init__(self, product)
    self.pub_client = pubc.KrakenPublicClient(timeout=10)

  def query_book(self):
    obj = self.pub_client.query_level_book(self.product)
    self.set_book_data(obj.req_timestamp, obj.res_timestamp, obj.msg)
